/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2011, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: PredSwingUtils.java
 Author....: Vyacheslav Kovalyov
 Created...: 23.10.11

 Description:

 ============================================================================*/
package ru.monyag.pred.swing.util;

import java.awt.*;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public abstract class PredSwingUtils {

    public static void setFrameToCenter(Window window) {

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

        int x = (int) ((screenSize.getWidth() - window.getWidth()) / 2);
        int y = (int) ((screenSize.getHeight() - window.getHeight()) / 2);

        window.setLocation(x, y);
    }

    public static int calculatePercentageSize(int base, int percentage) {

        if (percentage < 0) return 0;

        return (base * percentage) / 100;
    }
}
